package g

import "testing"

func Test_myAtoi(t *testing.T) {
	type args struct {
		s string
	}
	tests := []struct {
		name string
		args args
		want int
	}{
		{"1", args{"42"}, 42},
		{"2", args{"-42"}, -42},
		{"3", args{"41.93"}, 41},
		{"4", args{" 42"}, 42},
		{"5", args{" 042"}, 42},
		{"6", args{"  -42"}, -42},
		{"7", args{" -"}, 0},
		{"8", args{"  -  42"}, 0},
		{"9", args{"  "}, 0},
		{"10", args{"wer"}, 0},
		{"11", args{"4193 with words"}, 4193},
		{"12", args{"+1"}, 1},
		{"13", args{"21474836460"}, 2147483647},
		{"14", args{"  0000000000012345678"}, 12345678},
		{"15", args{"00000-42a1234"}, 0},
		{"16", args{"-000001"}, -1},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := myAtoi(tt.args.s); got != tt.want {
				t.Errorf("%v myAtoi() = %v, want %v", tt.name, got, tt.want)
			}
		})
	}
}
